package com.oneraku.service.utils;

import com.oneraku.service.exceptions.UnLoginException;
/**
 * @Author: hui.ren@huberbuy.com
 * @Date: 2019-07-24 14:07
 */
public class RequestUserUtils {
    private final static ThreadLocal<AuthBean> requestHolder = new ThreadLocal<AuthBean>();

    public static void add(AuthBean authUser) {
        requestHolder.set(authUser);
    }

    public static AuthBean getUser() {
        AuthBean authBean = requestHolder.get();
        if(null == authBean){
            throw new UnLoginException();
        }
        return authBean;
    }

    public static void remove() {
        requestHolder.remove();
    }
}
